using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CreaterService
{
    private static CreaterService _instance;

    public static CreaterService Instance
    {
        get
        {
            if (_instance == null)
            {
                _instance = new CreaterService();
            }

            return _instance;
        }
    }

    private Contexts _contexts;

    public void Init(Contexts contexts)
    {
        _contexts = contexts;
    }

    /// <summary>
    /// 创建游戏面板
    /// </summary>
    public GameEntity CreateGameBoard()
    {
        var entity = _contexts.game.CreateEntity();
        entity.AddGameBoard(7, 8);
        return entity;
    }

    /// <summary>生成元素</summary>
    public GameEntity CreateBall(CustomVector2 index)
    {
        var entity = _contexts.game.CreateEntity();
        entity.isGameBoardItem = true;
        entity.isMovable = true;
        entity.AddItemIndex(index);
        entity.AddLoadPrefab(RandomPathService.RandomPath());
        return entity;
    }

    /// <summary>生成障碍</summary>
    public GameEntity CreateBlock(CustomVector2 index)
    {
        var entity = _contexts.game.CreateEntity();
        entity.isGameBoardItem = true;
        entity.isMovable = false;
        entity.AddItemIndex(index);
        entity.AddLoadPrefab(Path.Bolcker);
        return entity;
    }
}